Component({
  data: {
    selected: 0,
    showTabBar: true, // 控制是否显示 TabBar
    showModal: false,
    showModal2: false,
    longitude: '',
    latitude: '',
    list: [
    ],

  },
  created() {
    const getDeviceInfo = wx.getDeviceInfo()
    if (getDeviceInfo.system.toLowerCase().includes('ios')) {
      wx.setStorageSync('phone', 'ios')
    }else{
      wx.setStorageSync('phone', 'android')
    }
  },
  methods: {

    // 显示 TabBar
    show() {
      this.setData({
        showTabBar: true,
      });
    },

    // 隐藏 TabBar
    hide() {
      this.setData({
        showTabBar: false
      });
    },

    switchTab(e) {
      const index = e.currentTarget.dataset.index
      const data = e.currentTarget.dataset;
      const url = data.path;
      if (index == 1) {
        // 更新选中的状态
        this.setData({
          selected: data.index
        });
        // 切换页面
        wx.switchTab({
          url
        });

      } else {
        // 更新选中的状态
        this.setData({
          selected: data.index
        });
        // 切换页面
        wx.switchTab({
          url
        });
      }
    }
  },

});